<template>
  <div>
    <div class="table-default" v-if="props.processData">
      <el-table :data="props.processData" class="mt-3" v-loading="loading" border row-key="id" :default-expand-all="expandFlag" :tree-props="{ children: 'detail', hasChildren: 'hasChildren' }">
        <el-table-column prop="sort" label="工序" min-width="80" />
        <el-table-column prop="process_code" label="工艺代码" min-width="110" />
        <el-table-column prop="process_name" label="工艺名称" width="120" />
        <el-table-column prop="make_qty" label="报工数量(父级)" width="100">
          <template #default="scope">
            <span v-if="scope.row.detail"> {{ Number(scope.row.make_qty) }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="report_qty" label="报工数量(子级)" width="100">
          <template #default="scope">
            <span v-if="!scope.row.detail"> {{ Number(scope.row.report_qty) }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="total_hours" label="总工时" min-width="100">
          <template #default="scope">
          {{ Number(scope.row.total_hours) }}  
        </template>
        </el-table-column>
        <el-table-column prop="hours" label="单位工时" min-width="100">
          <template #default="scope">
            <span v-if="!scope.row.detail"> {{ Number(scope.row.hours) }} </span>
          </template>
        </el-table-column>
        <el-table-column prop="people" label="人数" min-width="100" />
        <el-table-column prop="creator_id" label="创建人" />
        <el-table-column prop="created_at" label="创建时间" min-width="200" />
        <el-table-column prop="updated_at" label="更新时间" min-width="200" />
      </el-table>
      <Paginate />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const props = defineProps({
  processData: Number,
})

const loading = ref(true)
let expandFlag = ref(false)

if (props.processData) loading.value = false
</script>
  
  <style lang="css">
.backBtn {
  margin: 20px 10px;
}
</style>
  